package com.digitalart.site.section.subsectiontype {
	import com.digitalart.site.section.Section;
	import com.digitalart.site.section.subsectiontype.subsectionnav.NavController;

	import flash.events.Event;

	/**
	 * @author johan.chaves
	 */
	public class SubSectionType extends Section {
		
		public static const NAV_POS_X :  Number = 10;
		public static const NAV_POS_Y :  Number = 20;
		
		private var _nav : NavController;
		private var _subsectionController : SubSectionTypeController;
		
		public function SubSectionType() {
			setBackgroundSettings();		
		}

		public override function load() : void {
			
			_nav = new NavController();
			_nav.addEventListener(NavController.ON_NAV_READY, onNavReady);
			_nav.init(this.id);
		}

		private function onNavReady(event : Event) : void {
			
			_nav.getNav().x = NAV_POS_X;
			_nav.getNav().y = NAV_POS_Y;
			
			this.addChild(_nav.getNav());
			
			_subsectionController = new SubSectionTypeController();
			_subsectionController.addEventListener(SubSectionTypeController.SUB_SECTION_READY, onSubSectionReady);
			_subsectionController.init();			
		}

		private function onSubSectionReady(event : Event) : void {
			this.addChild(_subsectionController.subSectionView);
			dispatchEvent(new Event(Section.ON_LOAD_COMPLETE));
		}
	}
}
